********************************************************************************

			/*JOHANN/THOMAS: NEED FOR SUPPORT OR ECONOMIC COMPETITION*/

********************************************************************************


********************************************************************************
********************************************************************************
********************************************************************************

clear
set scheme s1mono
set more off

********************************************************************************
********************************************************************************
********************************************************************************

/*Data can be downloaded from the GESIS Data Archive ZA6594: 

https://dbk.gesis.org/dbksearch/sdesc2.asp?no=6594

Download is free of charge for non-commercial usage. Please 
register to access data.*/

use "[...]/ZA6594_en_v1-0-0.dta", clear


********************************************************************************
********************************************************************************
********************************************************************************


********************************************************************************

						/*DEPENDENT VARIABLES*/

********************************************************************************


// SC-IAT IMMIGRATION

sum w6_sciat*
gen d_w6 = w6_sciat_D
replace d_w6=. if w6_sciat_allerror25==1
replace d_w6=. if w6_sciat_fastdrop10==1
replace d_w6=. if w6_sciat_slowdrop10==1
sum w6_sciat*
tab id if w6_sciat_D_odds ==. & w6_sciat_D<.
replace  d_w6=. if w6_sciat_D_odds==.  
*drop if d_w6==. 
sum d_w6 w6_sciat*

gen     iat_kat=.
replace iat_kat=-7  if d_w6< -1.05 
replace iat_kat=-6  if d_w6< -0.90 & d_w6>=-1.05
replace iat_kat=-5  if d_w6< -0.75 & d_w6>=-0.90
replace iat_kat=-4  if d_w6< -0.60 & d_w6>=-0.75
replace iat_kat=-3  if d_w6< -0.45 & d_w6>=-0.60
replace iat_kat=-2  if d_w6< -0.30 & d_w6>=-0.45
replace iat_kat=-1  if d_w6< -0.15 & d_w6>=-0.30
replace iat_kat=0   if d_w6<  0    & d_w6>=-0.15
replace iat_kat=0   if d_w6>  0    & d_w6<=0.15
replace iat_kat=1   if d_w6>  0.15 & d_w6<=0.30
replace iat_kat=2   if d_w6>  0.30 & d_w6<=0.45
replace iat_kat=3   if d_w6>  0.45 & d_w6<=0.60
replace iat_kat=4   if d_w6>  0.60 & d_w6<=0.75
replace iat_kat=5   if d_w6>  0.75 & d_w6<=0.90
replace iat_kat=6   if d_w6>  0.90 & d_w6<=1.05
replace iat_kat=7   if d_w6>  1.05 
replace iat_kat=.   if d_w6==.

// FIGURE 1

histogram iat_kat, percent discrete  ///
  xlabel(-8 "stronger association with competition" 0"equally strong" ///
  7"stronger association with need", labsi(vsmall)) xtitle("") ///
  normal aspectratio(1)
 
 graph export "[...]/RRFigure1.pdf", as(pdf)  replace
 

// SC-IAT IMMIGRANTS RECATEGORIZED (SEE, GREENWALD ET AL., 2005; HAIDER ET AL., 2011)

gen     iat_kat3=.
replace iat_kat3=-1  if d_w6< -0.15 
replace iat_kat3=0   if d_w6<  0    & d_w6>=-0.15
replace iat_kat3=0   if d_w6>  0    & d_w6<=0.15
replace iat_kat3=1   if d_w6>  0.15 
replace iat_kat3=.   if d_w6==.

tab iat_kat iat_kat3

// SC-IAT IMMIGRANTS RESCALED FOR ANALYSIS

recode iat_kat3 (-1=1) (1=2) (0=0), gen(iat_kat3_rec)
label var iat_kat3_rec "SC-IAT (categorical)"
lab def iat_kat3_reclb 0"SC-IAT: Equally Strong" 1"SC-IAT: Economic Competition" ///
	2"SC-IAT: Need for Support"
lab val iat_kat3_rec iat_kat3_reclb

// POLICY PREFERENCES

tab w6_q4_12 
recode w6_q4_12 (1/2=1) (3=0) (4/5=2), gen(migrstop)
label def migrstoplb 0"Neutral" 1"Stop Migration" 2"Admit Migration"
label val migrstop migrstoplb

********************************************************************************

						/*INDEPENDENT VARIABLES*/

********************************************************************************

// DEMOGRAPHICS

// EDUCATION (QUALIFICATION FOR HIGHER EDUCATION (MATURA) = 1)

recode w1_sd7 (1/8=0) (9/15=1) (else=.), gen(edu)
tab     edu w1_sd7
label var edu "Education"
lab def edulb 1"Higher Education" 2"Lower Education"
lab val edu edulb

// GENDER (MALES = 1)

recode w1_sd3 (2=0) (1=1) (else=.), gen(male)
tab     male w1_sd3
label var male "Male"

// AGE (IN YEARS)

gen     age=2013-w1_sd2_year
label var age "Age"

// REGION
recode w6_sd1 (99=.)
tab    w6_sd1, gen(bl)
rename bl1 vorarlb
label var vorarlb "Vorarlberg"
rename bl2 tirol
label var tirol "Tyrol"
rename bl3 salzburg
label var salzburg "Salzburg"
rename bl4 oberoe
label var oberoe "Upper Austria"
rename bl5 kaernten
label var kaernten "Carinthia"
rename bl6 steiermark
label var steiermark "Styria"
rename bl7 burgenland
label var burgenland "Burgenland"
rename bl8 niederoe
label var niederoe "Lower Austria"
rename bl9 wien
label var wien "Vienna"

********************************************************************************

// ATTITUDES

// PARTY IDENTIFICATION

gen     pid=0 if w1_q33==2
replace pid=1 if w1_q34==1
replace pid=2 if w1_q34==2
replace pid=3 if w1_q34==3
replace pid=4 if w1_q34==5

label define pidlb 0"PID: None" 1"PID: SPOE" 2"PID: OEVP" 3"PID: FPOE" 4"PID: GREENS"
label values pid pidlb

gen     pid_spoe=0
replace pid_spoe=1 if w1_q34==1
replace pid_spoe=. if w1_q32==99
replace pid_spoe=. if w1_q32==88
replace pid_spoe=. if w1_q33==88
replace pid_spoe=. if w1_q33==99
replace pid_spoe=. if w1_q34==88
replace pid_spoe=. if w1_q34==99
tab     pid_spoe

label var pid_spoe "PID: SPOE" 

gen     pid_oevp=0
replace pid_oevp=1 if w1_q34==2
replace pid_oevp=. if w1_q32==99
replace pid_oevp=. if w1_q32==88
replace pid_oevp=. if w1_q33==88
replace pid_oevp=. if w1_q33==99
replace pid_oevp=. if w1_q34==88
replace pid_oevp=. if w1_q34==99
tab     pid_oevp

label var pid_oevp "PID: OEVP"

gen     pid_fpoe=0
replace pid_fpoe=1 if w1_q34==3
replace pid_fpoe=. if w1_q32==99
replace pid_fpoe=. if w1_q32==88
replace pid_fpoe=. if w1_q33==88
replace pid_fpoe=. if w1_q33==99
replace pid_fpoe=. if w1_q34==88
replace pid_fpoe=. if w1_q34==99
tab     pid_fpoe

label var pid_fpoe "PID: FPOE"

gen     pid_green=0
replace pid_green=1 if w1_q34==5
replace pid_green=. if w1_q32==99
replace pid_green=. if w1_q32==88
replace pid_green=. if w1_q33==88
replace pid_green=. if w1_q33==99
replace pid_green=. if w1_q34==88
replace pid_green=. if w1_q34==99
tab     pid_green

label var pid_green "PID: GREENS"

// MIGRATION BACKGROUND (MIGRATION BACKGROUND = 1)

recode w1_sd17 w1_sd18 (88/99=.)
gen     migrationh=0 if  w1_sd17==1 & w1_sd18==1
replace migrationh=1 if  w1_sd17>1  & w1_sd17<. 
replace migrationh=1 if  w1_sd18>1  & w1_sd18<. 
tab     migrationh
label def migrationhlb 1"Migration Background" 0"Native"
label val migrationh migrationhlb
label var migrationh "Migration Background"

// RELIGIOSITY 

tab w1_sd9a
recode w1_sd9a (1/2=0) (3/4=1) (else=.), gen(relig)
replace relig=0 if w1_sd9b==1
replace relig=0 if w1_sd9b==2
replace relig=1 if w1_sd9b==3
replace relig=1 if w1_sd9b==4
label var relig "Religiosity"

// DEMOCRACY SATISFACTION (SATISFIED = 1)

tab w6_q2 
recode w6_q2 (1/2=1) (3/4=0) (else=.), gen(demoz)
label var demoz "Democracy Satisfaction"

// EUROSCEPTICISM

recode w6_q43_1 (99=.), gen(eupride)
label var eupride "Euroscepticism"

// AUTHORITARIANISM

tab w1_q16_13
recode w1_q16_13 (77/99=.), gen(authorit)
label var authorit "Authoritarianism"


********************************************************************************
********************************************************************************
********************************************************************************


********************************************************************************

								/*ANALYSIS*/

********************************************************************************

// CATEGORICAL SC-IAT 

// MODEL 1: SC IAT IMMIGRATION (DV)

recode iat_kat3 (-1=0) (0=1) (1=2), gen(iatC)

mlogit iatC migrationh age edu demoz relig eupride ib3.i.pid vorarlb tirol ///
	salzburg oberoe kaernten steiermark burgenland niederoe, baseoutcome(0) 
estimates store xm2
*estadd fitstat

// FIGURE 2

coefplot xm2,keep(*:) drop(_cons) ||,xline(0, lpattern(shortdash))byopts(xrescale) ///
	level(95 90)ciopts(lcolor(black)) mcolor(black) msize(vsmall) ylab(, labsize(vsmall)) ///
	xlab(, labsize(vsmall)) aspectratio(1) grid(between glcolor(none)) yline(19) ///
	note("Reference category of SC-IAT is Economic Competition." "Reference category of PID is FPÖ." ///
	"Reference category of region is Vienna." ,size(vsmall))
graph export "[...]/RRFigure2.pdf", as(pdf)  replace	

outtex, level plain

// MODEL 2: PREFERENCE FOR STOPPING IMMIGRATION TO AUSTRIA (DV)

regress w6_q4_12 ib1.i.iat_kat3_rec migrationh age edu demoz relig eupride authorit ///
	ib3.i.pid vorarlb tirol salzburg oberoe kaernten steiermark burgenland niederoe 
estimates store zm1
estadd fitstat

// FIGURE 3

coefplot, drop(_cons) xline(0, lpattern(shortdash)) levels(95 90) ciopts(lcolor(black)) ///
 mcolor(black) msize(vsmall) ylab(, labsize(vsmall)) xlab(, labsize(vsmall)) aspectratio(1) ///
	grid(between glcolor(none)) note("Reference category of SC-IAT is Economic Competition." ///
	"Reference category of PID is FPÖ." "Reference category of region is Vienna." ,size(vsmall))
graph export "[...]/RRFigure3.pdf", as(pdf)  replace	

outtex, level plain

********************************************************************************
********************************************************************************
********************************************************************************


********************************************************************************

								/*APPENDIX*/

********************************************************************************

// ALTERNATIVE RESULTS METRIC SC-IAT 

// MODEL C1: SC IAT IMMIGRATION (DV)

regress d_w6 migrationh age edu demoz relig eupride ib3.i.pid vorarlb tirol salzburg oberoe kaernten steiermark burgenland niederoe
estimates store xn2
estadd fitstat

esttab xn* using "/Users/Kat/Documents/Kat's Docs/City, University of London/Papers/R&P/RR/M1.rtf", ///
    b(%7.2f) se(%6.2f) starlevels(# .10 * .05 ** .01 *** .001) ///
    scalars (r2 N) /// 
    onecell nogaps nodepvars compress noeqlines replace

outtex, level plain

// MODEL C2: PREFERENCE FOR STOPPING IMMIGRATION TO AUSTRIA (DV)

regress w6_q4_12 d_w6 migrationh age edu demoz relig eupride authorit ib3.i.pid vorarlb tirol salzburg oberoe kaernten steiermark burgenland niederoe 
estimates store zm3
estadd fitstat

outtex, level plain

********************************************************************************
********************************************************************************
********************************************************************************


********************************************************************************

								/*END OF DO-FILE*/

********************************************************************************
